/**
 * Filename: BaseIntentService.java
 * @author  Firefly
 * @contact postfirefly@163.com
 * @time    2016/2/29 18:43
 */
package com.github.postsanf.yinian;
import android.app.IntentService;
import android.widget.Toast;

import com.github.postsanf.yinian.utils.Logger;
import com.github.postsanf.yinian.utils.ToastUtils;
import com.google.gson.Gson;
import com.litesuits.http.HttpConfig;
import com.litesuits.http.LiteHttp;
/**
 * IntentService服务基类
 */
public abstract class BaseIntentService extends IntentService {
	protected String 						TAG;						// 标识
	protected BaseApplication 				application;				// 应用主体
	protected LiteHttp 						liteHttp;					// 网络访问
	protected Gson 							gson;						// json利器

	public BaseIntentService(String name) {
		super(name);
	}

	@Override
	public void onCreate() {
		super.onCreate();
		TAG 				= this.getClass().getSimpleName();
		application 		= (BaseApplication) getApplication();
		gson 				= new Gson();
		liteHttp 			= LiteHttp.newApacheHttpClient(new HttpConfig(this));
	}

	// 显示Toast
	protected void showToast(String msg)
	{
		ToastUtils.showToast(this, msg, Toast.LENGTH_SHORT);
	}
	// 输出日志
	protected void showLog(String msg)
	{
		Logger.show(TAG, msg);
	}
}
